The following methods return a boolean. All take a single character as their
parameter. If a string is passed, they will ignore all but the first character
of the string. If a null string is passed, they will return false.
Function isSpace(query as string) As Boolean
Returns true for space, return, and tab characters.
No dependency on other methods.
Function isChar(query as string) As Boolean
Returns true for all letters and digits.
No dependency on other methods.
Function isPunct(query as string) As boolean
Returns true for .,"';:! or ?
No dependency on other methods.
Function isLetter(query as string) As boolean
Returns true for all letters a-z and A-Z .
No dependency on other methods.
The following method returns a boolean, but accepts a string as its parameter.
Function hasNonSpace(entry as string) As Boolean
Returns true if any character in the passed string is not a return, tab, or space.
Depends on method "isSpace"
Example use:
you can use any of these as a test in a for/next statement:
if isPunct (theCharacter) then
Integer Methods
Function outStr(start as integer, base as string, search as string) As integer
Tells you how far from the right end of a string the last instance of the search string is. If a negative number is passed as start, the return value will be the distance from the end of the string. If zero or a positive value is passed, the distance from the start of the string will be returned
No dependency on other methods
String Reduction Methods
These methods accept at least one string as their parameter and all return a
string. If a null string is passed for any parameter, they return a null string.
For those which require an integer as a parameter, passing zero or a negative
number will result in a null string being returned.
Function nibbleLeft(entry as string) As String
Function nibbleRight(entry as string) As String
Function nibble(entry as string) As String
Remove space characters from the leading end, trailing end, or both ends, respectively.
Depend on method "isSpace" nibble depends on each of the ended methods.
Function chewRight(entry as string) As String
Function chewLeft(entry as string) As String
Function chew(entry as string) As String
Remove space and punctuation characters from the leading end, trailing end, or both
ends, respectively.
Depend on methods "isSpace" and "isPunct" chew depends on each of the ended
methods.
Function chompRight(entry as string) As String
Function chompLeft(entry as string) As String
Function chomp(entry as string) As String
Removes all characters which are not a letter or digit from the leading end,
trailing end, or both ends, respectively.
Depends on method "isChar" chomp depends on each of the ended methods.
Examples:
Let's say you had the following string (delineated by _'s):
_ "&$(!*#, another bug in my code!", he said.
_
passing it to nibble would return:
_"&$(!*#, another bug in my code!", he said._
as the leading spaces and trailing return are trimmed.
passing it to chew would give you:
_&$(!*#, another bug in my code!", he said_
as the spaces and punctuation are removed.
chomping it would return:
_another bug in my code!", he said_
getting rid of all those nasty symbols at the front.
Function splitLeft(entry as string, delimiter as string) As string
Function splitRight(entry as string, delimiter as string) As string
find the first instance of the delimiter and return the appropriate side of the string. Somewhat redundant, but faster than, the chompTo Functions.
No dependency on other methods.
Function nibbleToFromLeft(entry as string,target as string) As string
Removes any characters from the left end of the entry string up to and including
the first occurrance of the target string.
No dependency on other methods.
Function nibbleToFromRight(entry as string,target as string) As string
Removes the last occurrance of the target string and any characters following
it from the entry string.
No dependency on other methods.
Function chompToFromLeft(entry as string, target as string) As String
Removes all characters from the left end of the entry string up to and including
the final occurrance of the target string.
No dependency on other methods.
Function chompToFromRight(entry as string, target as string) As String
Removes the first occurance of the target string and all characters to the
right of it from the entry string.
No dependency on other methods.
Function chewToFromLeft(entry as string, target as string, occurrance as integer)
As string
Searches through the entry string for the target string. If it fails to find a number
of target strings equal or greater to the passed integer, it returns the entry string.
If it finds enough instances of the target string, it will remove all text up to and
including the occuranceth instance.
No dependencies on other methods.
Function chewToFromRight(entry as string, targetas string, occurrance as integer)
As string
Finds all instances of the target string in the entry string. If there are less
instances than the passed integer, it returns the entry string. Otherwise, it will
remove everything including and to the right of the occurranceth instance of the
target string.
No dependencies on other methods.
Examples:
Let's say you had the string
myString = "Now is the ti<>me for all go<>od men to joi<>n the party."
nibbleFromLeft (myString, "<>") would return:
me for all go<>od men to joi<>n the party.
chewFromLeft would return:
n the party.
and chewToFromLeft (myString, "<>", 2) would return:
od men to joi<>n the party.
Case Sensitive Methods:
Function csInStr(start as integer, base as string, query as string) As integer
Like inStr, but takes case into account.
Function csSplitLeft(base as string, target as string) As string
Function csSplitRight(base as string, target as string) As string
Split the base string at the target string, taking case into account
Depend on csInStr
Function csReplaceAll(base as string, target as string, replacement as string) As string
Taking case into account, replaces every instance of target in base with replacement.
depends on csInStr, csSplitLeft, csSplitRight
Get Text Methods:
These methods parse a string and return the requested instance of a specific type of text.
Function getWord(entry as string, instance as integer) As string
Words here are defined as one or more alpha-numeric characters separated from other characters by a space, tab, or return. Will concatenate a word at the end of a line that ends in a hyphen-return combination with the word on the following line.
Function getBracketedText(leftBracket as string, rightBracket as string,
instance as integer, entry as string) As String
Finds occurrance number instance of a block of text surrounded by the two passed
bracket string. Ignores blocks which are comprised entirely of space characters.
Reduces nested brackets. Returns a null string if any of the passed strings are
null or the passed integer is less than 1. Returns a null string if there are
less than instance occurrances of bracketed text. The left and right brackets are
allowed to be identical characters.
Depends on method "hasNonSpace"
Examples:
Let's say you're searching for text within an HTML document, which you've imported
as a string:
myString = "<HTML>
<b><i>My Page</b></i>
<b> This page has no content</b>
"
Now, you set up a loop that repeatedly calls the get bracketed text, feeding the results
This will fill the array with all instances of the text bracketed by > and <. I'll
go through the string and tell you what's in or out as far as the array's concerned.
The first instance of the left bracket is after HTML. The next right bracket is
before the b, but they surround a return, which is a space character, so this is
ignored. The next right bracket is before the i, but there is another occurrance
of the left bracket next to it. Since nested brackets are reduced to a single item,
the left bracket near HTML is ignored, and the one near b is evaluated. There's
nothing in between, so this is ignored, too.
The next right bracket is next to Page. It's left bracket is before My, so "My Page"
is the first string returned, and therefore becomes the first string added to the
array.
The two brackets between the tags following page are ignored because they surround
a null string. The two returns between /i> and <b are ignored, since returns are
space characters. " This page has no content" will be the next item added. After
that, there are no more occurrances of bracketed text, so a null string is returned,
and the loop exits.
The idea here is that, although many things are ignored, the method is designed to
give you a high probability of returning useful content.
Objects:
These were created to give you access to all of a type of text that is parsed from an entry string you provide. To use them, create an instance of the object, then supply the string to the appropriate method, and a boolean value will be returned to indicate whether any instances of the text were found. Instances are stored in an array. These depend on many of the simple methods described above.
bracketedObject
Works like getBracketed text, but finds all instances of bracketed text.
Call:
Function findAll(leftBracket as string, rightBracket as string, entry as string) As Boolean